package jy.game.components.wuxue.box;


import java.util.Locale;

import jy.game.components.role.JyRole;
import jy.game.components.wuxue.JyBuff;
import jy.game.components.wuxue.SkillCoverType;
import jy.game.components.wuxue.SkillCoverTypeHelper;
import jy.game.components.wuxue.SkillStatus;
import jy.game.components.wuxue.SkillType0;
import jy.game.tools.CommonSettings;
import jy.game.tools.ModData;
import wx.xml.simpleframework.xml.Attribute;

public abstract class JySkillBox {
    @Attribute public int        equipped = 1;
    // (get) Token: 0x0600033A RID: 826
    public            String     Name;
    // (get) Token: 0x0600033B RID: 827
    public /*Color*/  int        Color;
    // (get) Token: 0x0600033C RID: 828
    public            SkillType0 skillType;
    // (get) Token: 0x0600033D RID: 829
    //[XmlIgnore]
    public            String     Icon;
    // (get) Token: 0x06000342 RID: 834 RVA: 0x00003D48 File Offset: 0x00001F48
    // (set) Token: 0x06000343 RID: 835 RVA: 0x00003D50 File Offset: 0x00001F50
    //[XmlIgnore]
    public            JyRole     owner;

    // (get) Token: 0x0600033E RID: 830 RVA: 0x00003D2E File Offset: 0x00001F2E
    //[XmlIgnore]
//    public Sprite getIconSprite() {
//        return JyResource.GetIcon(this.icon);
//
//    }
    // (get) Token: 0x06000344 RID: 836
    public int            CostBall;
    // (get) Token: 0x06000345 RID: 837
    public int            costMp;
    // (get) Token: 0x06000346 RID: 838
    public int            Cd;
    // (get) Token: 0x06000347 RID: 839
    public int            Type;
    // (get) Token: 0x06000348 RID: 840
    public int            castSize;
    // (get) Token: 0x06000349 RID: 841
    public SkillCoverType coverType;
    // (get) Token: 0x0600034A RID: 842
    public int            size;
    // (get) Token: 0x0600034B RID: 843
    public String         animation;
    //[XmlIgnore]
    public int            currentCd;
    //[XmlIgnore]
    public String         screenEffect;
    //[XmlIgnore]
    public boolean        isScreenEffectFollowSprite;
    public int            attackResultHp;

    // (get) Token: 0x06000339 RID: 825 RVA: 0x00003D23 File Offset: 0x00001F23
    //[XmlIgnore]
    public boolean isUsed() {
        return this.equipped == 1;
    }

    public String GetSkillTypeChinese() {
        switch (this.skillType) {
            case Normal:
                return "外功";
            case Internal:
                return "内功";
            case Unique:
                return "绝技";
            case Special:
                return "特殊技能";
            case Aoyi:
                return "奥义";
            default:
                return "错误类型";
        }
    }

    public String getBuffsString() {
        String text = "";
        for (JyBuff buff : this.getBuffs()) {
            text += String.format("<color='yellow'>特效:%s(%s)</color>", buff.Name, buff.Level);
            if (buff.Round > 0) {
                text += String.format(" <color='yellow'>持续%s回合</color>", buff.Round);
            }
            if (buff.Property == 100) {
                text += String.format(" <color='red'>必定命中</color>");
            } else if (buff.Property > 0) {
                text += String.format(Locale.getDefault(), " <color='yellow'>命中概率:%d%%</color>", buff.Property);
            }
            text += "\n";
        }
        return text;
    }

    public String getSkillCoverTypeChinese() {
        return SkillCoverTypeHelper.GetSkillTypeChinese(this.coverType.value());
    }

    // (get) Token: 0x0600034C RID: 844 RVA: 0x00003D59 File Offset: 0x00001F59
    public int level() {
        return 1;
    }

    // (get) Token: 0x0600034D RID: 845 RVA: 0x00026828 File Offset: 0x00024A28
    public int maxLevel() {
        int num = Math.max(this.level(), ModData.getSkillMaxLevel(this.Name));
        if (num > CommonSettings.MAX_SKILL_LEVEL) {
            return CommonSettings.MAX_SKILL_LEVEL;
        }
        return num;
    }

    // (get) Token: 0x0600034E RID: 846 RVA: 0x00003D5C File Offset: 0x00001F5C
    public boolean hitSelf() {
        return false;
    }

    // (get) Token: 0x0600034F RID: 847 RVA: 0x00003D5F File Offset: 0x00001F5F
    public String audio() {
        return "";
    }

    // (get) Token: 0x06000350 RID: 848 RVA: 0x00003D66 File Offset: 0x00001F66
    public boolean isAoyi() {
        return this.skillType == SkillType0.Aoyi;
    }

    // (get) Token: 0x06000351 RID: 849 RVA: 0x00003D71 File Offset: 0x00001F71
    public boolean isUnique() {
        return this.skillType == SkillType0.Unique;
    }

    // (get) Token: 0x06000352 RID: 850 RVA: 0x00003D7C File Offset: 0x00001F7C
    public boolean isInternal() {
        return this.skillType == SkillType0.Internal;
    }

    // (get) Token: 0x06000353 RID: 851 RVA: 0x00003D87 File Offset: 0x00001F87
    public boolean isSpecial() {
        return this.skillType == SkillType0.Special;
    }

    // (get) Token: 0x06000354 RID: 852 RVA: 0x00003D92 File Offset: 0x00001F92
    //[XmlIgnore]
    public Iterable<JyBuff> getBuffs() {
        return null;
    }

    // (get) Token: 0x06000355 RID: 853 RVA: 0x00003D5C File Offset: 0x00001F5C
    public boolean tiaohe() {
        return false;
    }

//    public List<LocationBlock> GetSkillCastBlocks(int x, int y) {
//        List<LocationBlock> list = new ArrayList<LocationBlock>();
//        if (this.coverType == SkillCoverType.LINE || this.coverType == SkillCoverType.FAN || this.coverType == SkillCoverType.FRONT) {
//            if (x + 1 < BattleField.MAX_X) {
//                list.add(new LocationBlock {
//                    x = x + 1,
//                        y = y
//                });
//            }
//            if (y + 1 < BattleField.MAX_Y) {
//                list.add(new LocationBlock {
//                    x = x,
//                        y = y + 1
//                });
//            }
//            if (x - 1 >= 0) {
//                list.add(new LocationBlock {
//                    x = x + -1,
//                        y = y
//                });
//            }
//            if (y - 1 >= 0) {
//                list.add(new LocationBlock {
//                    x = x,
//                        y = y - 1
//                });
//            }
//            return list;
//        }
//        int castSize = this.getCastSize();
//        int max_X    = BattleField.MAX_X;
//        int max_Y    = BattleField.MAX_Y;
//        boolean  flag = false;
//        if (this.coverType != SkillCoverType.NORMAL || this.hitSelf) {
//            flag = true;
//        }
//        for (int i = -castSize; i <= castSize; i++) {
//            int num = x + i;
//            if (num >= 0 && num < max_X) {
//                for (int j = -castSize; j <= castSize; j++) {
//                    if ((flag || i != 0 || j != 0) && Math.Abs(i) + Math.Abs(j) <= castSize) {
//                        int num2 = y + j;
//                        if (num2 >= 0 && num2 < max_Y) {
//                            list.add(new LocationBlock {
//                                x = num,
//                                    y = num2
//                            });
//                        }
//                    }
//                }
//            }
//        }
//        return list;
//    }


//    public List<LocationBlock> GetSkillCoverBlocks(int x, int y, int spx, int spy) {
//        return new SkillCoverTypeHelper(this.coverType).GetSkillCoverBlocks(x, y, spx, spy, this.GetSize());
//    }

    // (get) Token: 0x06000356 RID: 854 RVA: 0x00003D9B File Offset: 0x00001F9B
    public double suit() {

        return 0f;

    }

    // (get) Token: 0x06000357 RID: 855 RVA: 0x00003D9B File Offset: 0x00001F9B
    public double power() {
        return 0f;
    }

    public void castCd() {
        this.currentCd += this.Cd;
    }

    // (get) Token: 0x06000359 RID: 857 RVA: 0x0002685C File Offset: 0x00024A5C
    public SkillStatus status() {

//        if (this.owner == null) {
//            return SkillStatus.Error;
//        }
//        if (this.owner.balls < this.costBall) {
//            return SkillStatus.NoBalls;
//        }
//        if (this.currentCd > 0) {
//            return SkillStatus.NoCd;
//        }
//        if (this.costMp > this.owner.mp) {
//            return SkillStatus.NoMp;
//        }
//        BattleSprite sprite = this.owner.Sprite;
//        if (CommonSettings.MOD_KEY >= 0 && sprite != null && this.isSpecial) {
//            boolean  flag = false;
//            if (this.name == "酒神" && (sprite.GetBuff("醉酒") == null || sprite.Role.jiushen_count >= 999 || sprite.Role.jiushen_count < 0)) {
//                flag = true;
//            } else if (sprite.GetBuff("特技封印") != null && this.name != "投降") {
//                flag = true;
//            }
//            if (flag) {
//                return SkillStatus.Seal;
//            }
//        }
//        if (sprite != null && !this.isSpecial
//            && ((sprite.GetBuff("诸般封印") != null && !this.isUnique)
//            || (sprite.GetBuff("拳掌封印") != null && this.itemType == 0)
//            || (sprite.GetBuff("剑封印") != null && this.itemType == 1)
//            || (sprite.GetBuff("刀封印") != null && this.itemType == 2)
//            || (sprite.GetBuff("奇门封印") != null && this.itemType == 3)
//            || (sprite.GetBuff("仙术封印") != null && this.itemType == 5))) {
//            return SkillStatus.Seal;
//        }
        return SkillStatus.Ok;

    }

    public String getStatusString() {
        switch (this.status()) {
            case Ok:
                return "正常";
            case NoBalls:
                return "怒气不足";
            case NoCd:
                return "冷却中";
            case NoMp:
                return "内力不足";
            case Seal:
                return "被封印";
            case Error:
                return "内部错误";
            default:
                return "内部错误";
        }
    }

    private int GetSize() {
        int num = this.size;
//        if (this.owner == null || this.owner.Sprite == null) {
//            Logger.e("error, skill owner or owner.sprite ==null");
//            return num;
//        }
//        BuffInstance buff = this.owner.Sprite.GetBuff("致盲");
//        if (buff != null && !this.owner.hasTalent("心眼通明")) {
//            int num2 = num;
//            num -= (int) (buff.level * 1.5);
//            if (num <= 0) {
//                if (num2 <= 0) {
//                    num = 0;
//                } else {
//                    num = 1;
//                }
//            }
//        }
//        if (this.owner.HasEquipmentTalent("直捣黄龙") && this.itemType == 3) {
//            num += 3;
//            if (this.name.StartsWith("岳家枪法") || this.name.StartsWith("军魂不灭.")) {
//                num++;
//            }
//        } else if (this.owner.hasTalent("寸长寸强")) {
//            num++;
//        }
        return num;
    }

    private int GetCastSize() {
        int num = this.castSize;
//        if (this.owner.hasTalent("吴钩霜雪") && this.name.StartsWith("太玄神功")) {
//            num += 3;
//        }
//        if (this.owner.hasTalent("金刚伏魔圈") && this.name == "日月神鞭") {
//            return 10;
//        }
//        if (num != 0) {
//            BuffInstance buff = this.owner.Sprite.GetBuff("致盲");
//            if (buff != null && !this.owner.hasTalent("心眼通明")) {
//                num -= (int) (buff.level * 1.5);
//                if (num <= 0) {
//                    num = 1;
//                }
//            }
//        }
//        if (CommonSettings.MOD_KEY == 0) {
//            return num;
//        }
//        return LuaManager.CallWithIntReturn("SKILL_getCastSize", new object[]
//            {
//                this,
//                this.owner,
//                num
//            });
        return num;
    }

    String getDescriptionInRichtext(boolean forAchievement) {
        return null;
    }

    protected String descriptionInRichtext() {
        return getDescriptionInRichtext(false);
    }

    //[XmlIgnore]
    public String descriptionInRichtextForAchievement() {
        return getDescriptionInRichtext(true);
    }

    // (get) Token: 0x06000360 RID: 864 RVA: 0x00003DD4 File Offset: 0x00001FD4
    //[XmlIgnore]
    public String descriptionInRichtextBlackBg() {
        return this.descriptionInRichtext().replace("black", "white");
    }

    //[XmlIgnore]
    public String descriptionInRichtextForAchievementBlackBg() {
        return this.descriptionInRichtextForAchievement().replace("black", "white");
    }

    public boolean tryAddExp(int exp, int maxLevel) {
        return false;
    }

    public String getTypeChinese() {
        switch (this.Type) {
            case 0:
                return "【拳系】";
            case 1:
                return "【剑系】";
            case 2:
                return "【刀系】";
            case 3:
                return "【奇门】";
            case 4:
                if (this.skillType == SkillType0.Internal) {
                    return "";
                }
                return "【内功】";
            case 5:
                return "【仙术】";
            default:
                return "";
        }
    }

    public int getCoverTypePower() {
        return new SkillCoverTypeHelper(this.coverType).GetCoverTypePower();
    }
}
